
#include "Knowledge.hpp"

Knowledge::Knowledge()
{

}

Knowledge::~Knowledge()
{

}

void Knowledge::addFact(char name, Tribool tb)
{
    this->_facts[name] = tb;
}

Tribool Knowledge::getFact(char name)
{
    if (this->_facts.find(name) != this->_facts.end())
        return this->_facts[name];
    return TriboolVal::Undefined;
}

void Knowledge::addRule(Rule const & rule)
{
    this->_unanalysedRules.push_back(rule);
}

void Knowledge::solveRules()
{
    std::list<Rule>::iterator it = this->_unanalysedRules.begin();
    while (it != this->_unanalysedRules.end())
    {
        std::cout << it->getAntecedents()->solve(*this) << std::endl;
        it++;
    }
}
